import json
import app

def build_add_data():
    json_file = app.BASE_PATH+"/data/employee.json"
    test_data = []
    with open(json_file,encoding="utf-8") as f:
        json_data = json.load(f)
        for case_data in json_data:
            desc = case_data.get("desc")
            employee_add_data = case_data.get('employee_add_data')
            test_data.append((desc,employee_add_data))
            # print("test_data = {}".format((addData)))
        return test_data

def build_update_data():
    json_file = app.BASE_PATH+"/data/updateEmployee.json"
    test_data = []
    with open(json_file,encoding="utf-8") as f:
        json_data = json.load(f)
        for case_data in json_data:
            desc = case_data.get("desc")
            employee_update_data = case_data.get('updata_data')
            test_data.append((desc,employee_update_data))
            # print("test_data = {}".format((employee_update_data)))
        return test_data

# 公共断言方法
def common_assert(case, response, status_code=200, success=True, code=10000, message="操作成功"):
    case.assertEqual(status_code, response.status_code)
    case.assertEqual(success, response.json().get("success"))
    case.assertEqual(code, response.json().get("code"))
    case.assertIn(message, response.json().get("message"))

# n = build_data()
# print(n)